package ocrs.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.TabPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class odinsFace implements EntryPoint {
	
RPCInterfaceAsync service = GWT.create(RPCInterface.class);
	
	public void onModuleLoad() {
	//	system = new OdinsFistSystem();
		RootPanel rootPanel = RootPanel.get();
		VerticalPanel mainPanel = new VerticalPanel();
		TextBox text = new TextBox();
		Button button = new Button("Push!");
		
		rootPanel.add(mainPanel);
		mainPanel.add(text);
		mainPanel.add(button);
		
		button.addClickHandler(new ClickHandler() {
		      public void onClick(ClickEvent event) {
		          hello();
		      }
		    });
		
		
		
	}
	
	public void hello()
	{
		if(service == null)
		{
			service = GWT.create(RPCInterface.class);
		}
		AsyncCallback<String> callback = new AsyncCallback<String>(){
			public void onFailure(Throwable caught)
			{
				Window.alert("Server failed: "+caught.getMessage());
			}
			
			public void onSuccess(String result) {
			        Window.alert(result);
			 }
		};
		
		service.helloServer(callback);
	}
	
//	public void onModuleLoad() {
//		//panel setup
//		RootPanel rootPanel = RootPanel.get();
//		rootPanel.setStyleName("body");
//		
//		VerticalPanel bigPanel = new VerticalPanel();
//		bigPanel.setStyleName("gwt-VerticalPanel-ocrs");
//		rootPanel.add(bigPanel, 0, 0);
//		bigPanel.setSize("496px", "347px");
//		
//		TabPanel pages = new TabPanel();
//		pages.setStyleName("gwt-TabPanelBottom");
//		
//		//set up header and body
//		Label lblOdinsFistHeader = new Label("ODIN'S FIST COURSE REGISTRATION SYSTEM");
//		lblOdinsFistHeader.setStyleName("gwt-Label-ocrsHeader");
//		bigPanel.add(lblOdinsFistHeader);
//		lblOdinsFistHeader.setSize("489px", "55px");
//		
//		bigPanel.add(pages); 
//		pages.setSize("493px", "288px");
//		
//		//add intro
//		//Image image = new Image();
//		//image.setUrl("440px-Odin55.jpg");
//		LoginPage login = new LoginPage();
//		pages.add(login, "Intro");
//		pages.setVisible(true);
//		//image.setSize("461", "246px");
//		
//		//add 2nd page
//		MainPage studentMain = new MainPage();
//		studentMain.setHeight("110px");
//		//studentMain.setHeight("194px");
//		pages.add(studentMain, "Home");
//		
//		//add form entry
//		DataEntry userEntry =  new DataEntry();
//		pages.add(userEntry, "Create New User");
//		
//		
//		//make tabs
//
//		
//	}
}
